<template>
  <el-select v-model="value" filterable :placeholder="placeholder" @change="changeValue($event)" clearable style="width:100%">
    <el-option
      v-for="item in locations"
      :key="item.code"
      :label="item.serialNumber"
      :value="item.code"
    />
  </el-select>
</template>
<script>
  import request from '@/utils/request'
  export default {
    data() {
      return {
        value: '',
        locations: [],
        locationName: '',
      }
    },
    props: {
      placeholder: {
        type: String,
        default: '请选择所属库库位'
      },
    },
    created() {

    },
    methods: {
      findList(parentCode) {
        this.locations = []
        this.value = ''
        // 父节点为空时不查询，并清空数据
        if(parentCode != '' && parentCode != null){
          return request({
            url: '/wms/location/chooseAllData',
            method: 'get',
            params: { spaceCode: parentCode }
          }).then(response => {
            this.locations = response.data
          })
        }
      },

      changeValue(val) {
        this.$emit("setLocationCode", val)
      },
    }
  }
</script>
